home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / macros / latex209 / contrib / epsfig / epsfig.sty < prev    next >
Text File  |  1994-01-26  |  42KB  |  1,138 lines

  1. %----------------------------------------------
  2. \def\fileversion{v1.20}%
  3. \def\filedate{26.1.94}%
  4. %%%
  5. %%% from a suggestion by eijkhout@csrd.uiuc.edu to allow
  6. %%% loading as a style file:
  7. \edef\epsfigRestoreAt{\catcode`@=\number\catcode`@\relax}%
  8. \catcode`\@=11\relax
  9. \ifx\undefined\@makeother                % -pks-
  10. \def\@makeother#1{\catcode`#1=12\relax}  % -pks-
  11. \fi                                      % -pks-
  12. \immediate\write16{Document style option `epsfig', \fileversion\space
  13. <\filedate> (edited by SPQR)}%
  14. %%%--------------------------------------------------------------------
  15. %%% psfig merged with EPSF = epsfig Release 1
  16. %%% 1.0 November 91
  17. %%% 1.1 Dec 91  fixed some bugs
  18. %%% 1.2 Jan 92  fixed bug that it never stopped reading PS file until
  19. %%%             it reached the end! merged in changes from psfig1.8
  20. %%%             (plain TeX definition of \fbox, new code for rotation)
  21. %%% 1.3 Jan 92  separated out \special code so that dvitops can be
  22. %%%             supported. use \psfigdriver{dvitops}%
  23. %%% 1.4 Jan 92  fixed dvitops. need to input psfig at different point
  24. %%%      in dvips from dvitops. define \psfig@start and \psfig@end to cope
  25. %%%      with this
  26. %%% 1.5 Jan 92  force use of psfig method if using dvitops
  27. %%% 1.6 May 92 fixed bugs
  28. %%% 1.7 Sep 92 added support for emtex, sort of. reads a .bb file
  29. %%%            and imports .pcx file. Boolean flag \epsfigdos used
  30. %%%             to indicate that we cannot have more than one . in the
  31. %%%             suffix (ie we will look at file.bb not file.eps.bb)
  32. %%%
  33. %%% 1.8 Sep 92 added support for OzTeX; fixed bugs in dvips support
  34. %%% (including clipping to bounding box); removed use of dimen100.
  35. %%%
  36. %%% 1.9 Dec 92 cleaned up documentation again
  37. %%% 1.10 Mar 93 cleaned up for plain TeX
  38. %%% 1.11 Mar 93 merged in changes by Peter Galko (supplied by CERN) for
  39. %%%             use with Textures
  40. %%% 1.12 Apr 93 actually *tested* the Textures additions, and so rewrote
  41. %%%            from scratch (borrowed an idea from psbox)
  42. %%% 1.13 May 93 allow for file names with _ or $ in them in \psdraft, and
  43. %%%             fix problem that occurred with missing BoundingBox
  44. %%% 1.14 May 93 allow for .z suffix
  45. %%% 1.15 July 93 allow for .gz suffix
  46. %%%              use \leavevmode as appropriate
  47. %%%              fix plain \TeX mode 
  48. %%%             (fixes from Peter-Klaus Schilling <R02SCH@DSYIBM.DESY.DE>)
  49. %%% 1.16 August 93 [peta@mcrcim.mcgill.edu (Peter Whaite)]
  50. %%%        -- Implement Perl scripts to do compressed file inclusion and bb
  51. %%%           generation. 
  52. %%%        -- Add \pscompress.
  53. %%%        -- Tidy up comments.
  54. %%% 1.17 September 93 SPQR
  55. %%%     better code for literal name printing
  56. %%%     allowed for spaces around , and =
  57. %%% 1.18 17.9.93
  58. %%%   updates to epsbb and epsfig from Peter W
  59. %%% 1.19 14.11.93
  60. %%%   mistaken placement of calculation of EPS@Height resulted in errors
  61. %%% 1.20 defaults to no compression
  62. %--------------------------------------------------------
  63. %%%
  64. %%% code rearranged by Sebastian Rahtz (spqr@uk.ac.york.minster)
  65. %%% from work by
  66. %%% Trevor Darrell; Tom Rokicki; Daniel Smith; H. Payne, Robert Russell
  67. %%%
  68. %%% This is a version of Darrell's `psfig' macros which are designed
  69. %%% to be used with dvips or dvitops, and the `epsf' macros (these are
  70. %%% automaticaly included by the style file). I did this because the
  71. %%% \special commands used by `epsf' appear to be more robust and
  72. %%% portable than the raw \specials used by `psfig', but I preferred
  73. %%% the psfig interface. This system preserves the psfig interface,
  74. %%% but mainly uses epsf macros to carry out the job. The user
  75. %%% interface is identical to \psfig, but you just use \epsfig
  76. %%% instead. Rotation uses the original psfig macros: I could not work
  77. %%% out how to do rotation with the epsf macros.
  78. %%%
  79. %%% The same applies to `rheight' and `rwidth'
  80. %%%
  81. %%% If you *really* want old psfig behaviour regardless, use \psfig. It is
  82. %%% still there. Some of the features have gone, however. \figurepath
  83. %%% seemed redundant, since it could be controlled by the TEXINPUTS
  84. %%% variable anyway.
  85. %%%
  86. %%% As an added feature, if FILE cannot be found, a file called FILE.bb
  87. %%% is searched for. This should simply contain a %%BoundingBox line. A perl
  88. %%% script "epsbb" is provided to generate these automatically.  It is
  89. %%% assumed that if this exists, then the actual postscript is in UNIX
  90. %%% compress format in FILE.Z or in GNU gzip format in FILE.gz or FILE.z.
  91. %%%
  92. %%% The macros then read the BB from FILE.bb, but insert "`epsfig FILE`" in
  93. %%% the  output for dvips to interpret (don't worry, it knows about this).
  94. %%% "Epsfig" is another perl script which  searches the TEXINPUTS path for
  95. %%% FILE or FILE.{gz,z,Z}.
  96. %%%
  97. %%% As an added bonus if you say \pscompress the -c switch will be passed to
  98. %%% epsfig, causing automatic FILE.bb generation and compression the first
  99. %%% time dvips is run.  Files in the system directories will NOT be
  100. %%% compressed.
  101. %%% If you are *not* on a Unix system and use this, deliberately or by
  102. %%% mischance, you will have problems!
  103. %%%
  104. %%% This file can be included in a dumped format, or used as a LaTeX
  105. %%% style file, or used in plain TeX. It does not load itself twice (I hope)
  106. %%%
  107. %--------------------------------------------------------------------
  108. %--------------------------------------------------------------------
  109. %%% previous notes. this copy of psfig.tex inherited from versions 1.8
  110. %--------------------------------------------------------------------
  111. %%% All psfig/tex software, documentation, and related files
  112. %%% in this distribution of psfig/tex are
  113. %%% Copyright 1987, 1988, 1991 Trevor J. Darrell
  114. %
  115. %%% Permission is granted for use and non-profit distribution of psfig/tex
  116. %%% providing that this notice be clearly maintained. The right to
  117. %%% distribute any portion of psfig/tex for profit or as part of any commercial
  118. %%% product is specifically reserved for the author(s) of that portion.
  119. %%%
  120. %%% Thanks to Greg Hager (GDH) and Ned Batchelder for their contributions
  121. %%% to this project.
  122. %%%--------------------------------------------------------------------------
  123. %%% GDH 7/26/87 -- changed so that it first looks in the local directory,
  124. %%% then in a specified global directory for the ps file.
  125. %%% SPQR 12/91 removed that last change. it follows TEXINPUTS anyway
  126. %%% RPR 6/25/91 -- changed so that it defaults to user-supplied name if
  127. %%% boundingbox info is specified, assuming graphic will be created by
  128. %%% print time.
  129. %%% SPQR 12/91 removed that last change. use LaTeX error message instead
  130. %%% SPQR 12/91 -- `no file found' produces LaTeX error message.
  131. %%%                If you recover from that the file name is set in draft
  132. %%%                mode in place of the file.
  133. %%%
  134. %%% Modified by J. Daniel Smith on 9 October 1990 to accept the
  135. %%% %%BoundingBox: comment with or without a space after the colon.  Stole
  136. %%% file reading code from Tom Rokicki's EPSF.TEX file (see below).
  137. %%% --- SPQR 12.91 removed most of this to use epsf directly
  138. %%%
  139. %%% More modifications by J. Daniel Smith on 29 March 1991 to allow the
  140. %%% the included PostScript figure to be rotated.  The amount of
  141. %%% rotation is specified by the "angle=" parameter of the \epsfig command.
  142. %%%
  143. %%% Modified by Robert Russell on June 25, 1991 to allow users to specify
  144. %%% .ps filenames which don't yet exist, provided they explicitly provide
  145. %%% boundingbox information via the \epsfig command. Note: This will only work
  146. %%% if the "file=" parameter follows all four "bb???=" parameters in the
  147. %%% command. This is due to the order in which psfig interprets these params.
  148. %%% ---- SPQR 12.91 removed all this
  149. %%%
  150. %%% 3 Jul 1991  JDS     check if file already read in once
  151. %%%
  152. %-----------------------------USAGE---------------------------------------
  153. % From: gvr@cs.brown.edu (George V. Reilly)
  154. %
  155. % \psdraft      draws an outline box, but doesn't include the figure
  156. %               in the DVI file.  Useful for previewing.
  157. %
  158. % \psfull       includes the figure in the DVI file (default).
  159. %
  160. % \psscalefirst width= or height= specifies the size of the figure
  161. %               before rotation.
  162. % \psrotatefirst (default) width= or height= specifies the size of the
  163. %                figure after rotation.  Asymetric figures will
  164. %                appear to shrink.
  165. %
  166. % usage: \epsfig{file=, figure=, height=, width=,
  167. %                       bbllx=, bblly=, bburx=, bbury=,
  168. %                       rheight=, rwidth=, clip=, angle=, silent=}%
  169. %
  170. %       "file" is the filename.  If no path name is specified and the
  171. %               file is not found in the current directory,
  172. %               it will be looked for in directory \psfigurepath.
  173. %       "figure" is a synonym for "file".
  174. %       By default, the width and height of the figure are taken from
  175. %               the BoundingBox of the figure.
  176. %       If "width" is specified, the figure is scaled so that it has
  177. %               the specified width.  Its height changes proportionately.
  178. %       If "height" is specified, the figure is scaled so that it has
  179. %               the specified height.  Its width changes proportionately.
  180. %       If both "width" and "height" are specified, the figure is scaled
  181. %               anamorphically.
  182. %       "bbllx", "bblly", "bburx", and "bbury" control the PostScript
  183. %               BoundingBox.
  184. %       "rheight" and "rwidth" are the reserved height and width
  185. %               of the figure, i.e., how big TeX actually thinks
  186. %               the figure is.  They default to "width" and "height".
  187. %       The "clip" option ensures that no portion of the figure will
  188. %               appear outside its BoundingBox.  "clip=" is a switch and
  189. %               takes no value, but the `=' must be present.
  190. %       The "angle" option specifies the angle of rotation (degrees, ccw).
  191. %       The "silent" option makes \psfig work silently.
  192. %
  193. %--------------------------------------------------------------------------
  194. \newcount\EPS@Height \newcount\EPS@Width \newcount\EPS@xscale
  195. \newcount\EPS@yscale
  196. \def\psfigdriver#1{%
  197.   \bgroup\edef\next{\def\noexpand\tempa{#1}}%
  198.     \uppercase\expandafter{\next}%
  199.     \def\LN{DVITOLN03}%
  200.     \def\DVItoPS{DVITOPS}%
  201.     \def\DVIPS{DVIPS}%
  202.     \def\emTeX{EMTEX}%
  203.     \def\OzTeX{OZTEX}%
  204.     \def\Textures{TEXTURES}%
  205.     \global\chardef\fig@driver=0
  206.     \ifx\tempa\LN
  207.         \global\chardef\fig@driver=0\fi
  208.     \ifx\tempa\DVItoPS
  209.         \global\chardef\fig@driver=1\fi
  210.     \ifx\tempa\DVIPS
  211.         \global\chardef\fig@driver=2\fi
  212.     \ifx\tempa\emTeX
  213.         \global\chardef\fig@driver=3\fi
  214.     \ifx\tempa\OzTeX
  215.         \global\chardef\fig@driver=4\fi
  216.     \ifx\tempa\Textures
  217.         \global\chardef\fig@driver=5\fi
  218.   \egroup
  219. \def\psfig@start{}%
  220. \def\psfig@end{}%
  221. \def\epsfig@gofer{}%
  222. \ifcase\fig@driver
  223. % case 0 ln03
  224. \typeout{WARNING! ****
  225.  no specials for LN03 psfig}%
  226. %
  227. \or % case 1: dvitops
  228. \def\psfig@start{}%
  229. \def\psfig@end{\special{dvitops: import \@p@sfilefinal \space
  230. \@p@swidth sp \space \@p@sheight sp \space fill}%
  231. \if@clip \typeout{Clipping not supported}\fi
  232. \if@angle \typeout{Rotating not supported}\fi
  233. }%
  234. \let\epsfig@gofer\psfig@end
  235. %
  236. \or %case2 dvips
  237. \def\psfig@start{\special{ps::[begin]  \@p@swidth \space \@p@sheight \space%
  238.         \@p@sbbllx \space \@p@sbblly \space%
  239.         \@p@sbburx \space \@p@sbbury \space%
  240.         startTexFig \space }%
  241.         \if@angle
  242.                 \special {ps:: \@p@sangle \space rotate \space}
  243.         \fi
  244.         \if@clip
  245.                 \if@verbose
  246.                         \typeout{(clipped to BB) }%
  247.                 \fi
  248.                 \special{ps:: doclip \space }%
  249.         \fi
  250.         \special{ps: plotfile \@p@sfilefinal \space }%
  251.         \special{ps::[end] endTexFig \space }%
  252. }%
  253. \def\psfig@end{}%
  254. \def\epsfig@gofer{\if@clip
  255.                         \if@verbose
  256.                            \typeout{(clipped to BB)}%
  257.                         \fi
  258.                         \epsfclipon
  259.                   \fi
  260.                   \epsfsetgraph{\@p@sfilefinal}%
  261. }%
  262. %
  263. \or % case 3, emTeX
  264. \typeout{WARNING. You must have a .bb info file with the Bounding Box
  265.   of the pcx file}%
  266. \def\psfig@start{}%
  267. % when emtex imports a pcx file, it is *below* where we are now.
  268. % so raise the box
  269. \def\psfig@end{\typeout{pcx import of \@p@sfilefinal}%
  270. \if@clip \typeout{Clipping not supported}\fi
  271. \if@angle \typeout{Rotating not supported}\fi
  272. \raisebox{\@p@srheight sp}{\special{em: graph \@p@sfilefinal}}}%
  273. \def\epsfig@gofer{}%
  274. %
  275. \or % case 4, OzTeX
  276. \def\psfig@start{}%
  277. \def\psfig@end{%
  278. \EPS@Width\@p@swidth
  279. \EPS@Height\@p@sheight
  280. \divide\EPS@Width by 65781  % convert sp to bp
  281. \divide\EPS@Height by 65781
  282. \special{epsf=\@p@sfilefinal
  283. \space
  284. width=\the\EPS@Width
  285. \space
  286. height=\the\EPS@Height
  287. }%
  288. \if@clip \typeout{Clipping not supported}\fi
  289. \if@angle \typeout{Rotating not supported}\fi
  290. }%
  291. \let\epsfig@gofer\psfig@end
  292. \or % case 5, Textures
  293. \def\psfig@end{
  294. % what is scaling of picture
  295.          \EPS@Width=\@bbw  
  296.          \divide\EPS@Width by 1000
  297.          \EPS@xscale=\@p@swidth \divide \EPS@xscale by \EPS@Width
  298.          \EPS@Height=\@bbh  
  299.          \divide\EPS@Height by 1000
  300.          \EPS@yscale=\@p@sheight \divide \EPS@yscale by\EPS@Height
  301. % take largest calculated scale
  302.   \ifnum\EPS@xscale>\EPS@yscale\EPS@xscale=\EPS@yscale\fi
  303. \if@clip
  304.    \if@verbose
  305.       \typeout{(clipped to BB)}%
  306.    \fi
  307.    \epsfclipon
  308. \fi
  309. \special{illustration \@p@sfilefinal\space scaled \the\EPS@xscale}%
  310. }%
  311. \def\psfig@start{}%
  312. \let\epsfig\psfig
  313. \else
  314. \typeout{WARNING. *** unknown  driver - no psfig}%
  315. \fi
  316. }%
  317. % copies of bits of LaTeX we need....
  318. \newdimen\ps@dimcent
  319. %
  320. % \fbox is defined in latex.tex; so if \fbox is undefined, assume that
  321. % we are not in LaTeX.
  322. % Perhaps this could be done better???
  323. \ifx\undefined\fbox
  324. % \fbox code from modified slightly from LaTeX
  325. \newdimen\fboxrule
  326. \newdimen\fboxsep
  327. \newdimen\ps@tempdima
  328. \newbox\ps@tempboxa
  329. \fboxsep = 0pt
  330. \fboxrule = .4pt
  331. \long\def\fbox#1{\leavevmode\setbox\ps@tempboxa\hbox{#1}\ps@tempdima\fboxrule
  332.     \advance\ps@tempdima \fboxsep \advance\ps@tempdima \dp\ps@tempboxa
  333.    \hbox{\lower \ps@tempdima\hbox
  334.   {\vbox{\hrule height \fboxrule
  335.           \hbox{\vrule width \fboxrule \hskip\fboxsep
  336.           \vbox{\vskip\fboxsep \box\ps@tempboxa\vskip\fboxsep}\hskip
  337.                  \fboxsep\vrule width \fboxrule}%
  338.                  \hrule height \fboxrule}}}}%
  339. \fi
  340. \ifx\@ifundefined\undefined
  341. \long\def\@ifundefined#1#2#3{\expandafter\ifx\csname
  342.   #1\endcsname\relax#2\else#3\fi}%
  343. \fi
  344. %
  345. \@ifundefined{typeout}%
  346. {\gdef\typeout#1{\immediate\write\sixt@@n{#1}}}%
  347. {\relax}%
  348. %
  349. %%% check to see if macros already loaded in (maybe some other file says
  350. %%% "\input epsfig") ...
  351. \@ifundefined{epsfig}{}{\typeout{EPSFIG --- already loaded}\endinput}%
  352. %
  353. %%%
  354. %%% we need Rokicki's EPSF macros anyway, unless they are already loaded
  355. %
  356. \@ifundefined{epsfbox}{\input epsf}{}%
  357. %
  358. %% SPQR 12.91 handling of errors using standard LaTeX error
  359. %% mechanism. In case we are plain TeX we first define the
  360. %% error routines...
  361. \ifx\undefined\@latexerr
  362.         \newlinechar`\^^J
  363.         \def\@spaces{\space\space\space\space}%
  364.         \def\@latexerr#1#2{%
  365.         \edef\@tempc{#2}\expandafter\errhelp\expandafter{\@tempc}%
  366.         \typeout{Error. \space see a manual for explanation.^^J
  367.          \space\@spaces\@spaces\@spaces Type \space H <return> \space for
  368.          immediate help.}\errmessage{#1}}%
  369. \fi
  370. %------------------------
  371. %% a couple of LaTeX error messages
  372. \def\@whattodo{You tried to include a PostScript figure which
  373. cannot be found^^JIf you press return to carry on anyway,^^J
  374. The failed name will be printed in place of the figure.^^J
  375. or type X to quit}%
  376. \def\@whattodobb{You tried to include a PostScript figure which
  377. has no^^Jbounding box, and you supplied none.^^J
  378. If you press return to carry on anyway,^^J
  379. The failed name will be printed in place of the figure.^^J
  380. or type X to quit}%
  381. %------------------------
  382. %
  383. %------------------------------------------------------------------------
  384. %------------------------------------------------------------------------
  385. %%% @psdo control structure -- similar to Latex @for.
  386. %%% I redefined these with different names so that psfig can
  387. %%% be used with TeX as well as LaTeX, and so that it will not
  388. %%% be vunerable to future changes in LaTeX's internal
  389. %%% control structure,
  390. %
  391. \def\@nnil{\@nil}%
  392. \def\@empty{}%
  393. \def\@psdonoop#1\@@#2#3{}%
  394. \def\@psdo#1:=#2\do#3{\edef\@psdotmp{#2}\ifx\@psdotmp\@empty \else
  395.     \expandafter\@psdoloop#2,\@nil,\@nil\@@#1{#3}\fi}%
  396. \def\@psdoloop#1,#2,#3\@@#4#5{\def#4{#1}\ifx #4\@nnil \else
  397.        #5\def#4{#2}\ifx #4\@nnil \else#5\@ipsdoloop #3\@@#4{#5}\fi\fi}%
  398. \def\@ipsdoloop#1,#2\@@#3#4{\def#3{#1}\ifx #3\@nnil
  399.        \let\@nextwhile=\@psdonoop \else
  400.       #4\relax\let\@nextwhile=\@ipsdoloop\fi\@nextwhile#2\@@#3{#4}}%
  401. \def\@tpsdo#1:=#2\do#3{\xdef\@psdotmp{#2}\ifx\@psdotmp\@empty \else
  402.     \@tpsdoloop#2\@nil\@nil\@@#1{#3}\fi}%
  403. \def\@tpsdoloop#1#2\@@#3#4{\def#3{#1}\ifx #3\@nnil
  404.        \let\@nextwhile=\@psdonoop \else
  405.       #4\relax\let\@nextwhile=\@tpsdoloop\fi\@nextwhile#2\@@#3{#4}}%
  406. %%%
  407. %
  408. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  409. %%% file reading stuff from epsf.tex
  410. %%%   EPSF.TEX macro file:
  411. %%%   Written by Tomas Rokicki of Radical Eye Software, 29 Mar 1989.
  412. %%%   Revised by Don Knuth, 3 Jan 1990.
  413. %%%   Revised by Tomas Rokicki to accept bounding boxes with no
  414. %%%      space after the colon, 18 Jul 1990.
  415. %%%   Portions modified/removed for use in PSFIG package by
  416. %%%      J. Daniel Smith, 9 October 1990.
  417. %%%   Just the bit which knows about (atend) as a BoundingBox
  418. %
  419. %%%    hacked back a bit by SPQR 12/91
  420. %
  421. \long\def\epsfaux#1#2:#3\\{\ifx#1\epsfpercent
  422.    \def\testit{#2}\ifx\testit\epsfbblit
  423.         \@atendfalse
  424.         \epsf@atend #3 . \\%
  425.         \if@atend
  426.            \if@verbose
  427.                 \typeout{epsfig: found `(atend)'; continuing search}%
  428.            \fi
  429.         \else
  430.                 \epsfgrab #3 . . . \\%
  431.                 \epsffileokfalse\global\no@bbfalse
  432.                 \global\epsfbbfoundtrue
  433.         \fi
  434.    \fi\fi}%
  435. %
  436. %%% Determine if the stuff following the %%BoundingBox is `(atend)'
  437. %%% J. Daniel Smith.  Copied from \epsf@grab above.
  438. %
  439. \def\epsf@atendlit{(atend)}
  440. %
  441. \def\epsf@atend #1 #2 #3\\{%
  442.    \def\epsf@tmp{#1}\ifx\epsf@tmp\empty
  443.       \epsf@atend #2 #3 .\\\else
  444.    \ifx\epsf@tmp\epsf@atendlit\@atendtrue\fi\fi}%
  445.  
  446.  
  447. %%% End of file reading stuff from epsf.tex
  448. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  449.  
  450. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  451. %%% trigonometry stuff from "trig.tex"
  452. \chardef\trig@letter = 11
  453. \chardef\other = 12
  454.  
  455. \newif\ifdebug %%% turn me on to see TeX hard at work ...
  456. \newif\ifc@mpute %%% don't need to compute some values
  457. \newif\if@atend
  458. \c@mputetrue % but assume that we do
  459.  
  460. \let\then = \relax
  461. \def\r@dian{pt }%
  462. \let\r@dians = \r@dian
  463. \let\dimensionless@nit = \r@dian
  464. \let\dimensionless@nits = \dimensionless@nit
  465. \def\internal@nit{sp }%
  466. \let\internal@nits = \internal@nit
  467. \newif\ifstillc@nverging
  468. \def \Mess@ge #1{\ifdebug \then \message {#1} \fi}%
  469.  
  470. { %%% Things that need abnormal catcodes %%%
  471.         \catcode `\@ = \trig@letter
  472.         \gdef \nodimen {\expandafter \n@dimen \the \dimen}%
  473.         \gdef \term #1 #2 #3%
  474.                {\edef \t@ {\the #1}%%% freeze parameter 1 (count, by value)
  475.                 \edef \t@@ {\expandafter \n@dimen \the #2\r@dian}%
  476.                                    %%% freeze parameter 2 (dimen, by value)
  477.                 \t@rm {\t@} {\t@@} {#3}%
  478.                }%
  479.         \gdef \t@rm #1 #2 #3%
  480.                {{%
  481.                 \count 0 = 0
  482.                 \dimen 0 = 1 \dimensionless@nit
  483.                 \dimen 2 = #2\relax
  484.                 \Mess@ge {Calculating term #1 of \nodimen 2}%
  485.                 \loop
  486.                 \ifnum  \count 0 < #1
  487.                 \then   \advance \count 0 by 1
  488.                         \Mess@ge {Iteration \the \count 0 \space}%
  489.                         \Multiply \dimen 0 by {\dimen 2}%
  490.                         \Mess@ge {After multiplication, term = \nodimen 0}%
  491.                         \Divide \dimen 0 by {\count 0}%
  492.                         \Mess@ge {After division, term = \nodimen 0}%
  493.                 \repeat
  494.                 \Mess@ge {Final value for term #1 of
  495.                                 \nodimen 2 \space is \nodimen 0}%
  496.                 \xdef \Term {#3 = \nodimen 0 \r@dians}%
  497.                 \aftergroup \Term
  498.                }}%
  499.         \catcode `\p = \other
  500.         \catcode `\t = \other
  501.         \gdef \n@dimen #1pt{#1} %%% throw away the ``pt''
  502. }%
  503.  
  504. \def \Divide #1by #2{\divide #1 by #2} %%% just a synonym
  505.  
  506. \def \Multiply #1by #2%%% allows division of a dimen by a dimen
  507.        {{%%% should really freeze parameter 2 (dimen, passed by value)
  508.         \count 0 = #1\relax
  509.         \count 2 = #2\relax
  510.         \count 4 = 65536
  511.         \Mess@ge {Before scaling, count 0 = \the \count 0 \space and
  512.                         count 2 = \the \count 2}%
  513.         \ifnum  \count 0 > 32767 %%% do our best to avoid overflow
  514.         \then   \divide \count 0 by 4
  515.                 \divide \count 4 by 4
  516.         \else   \ifnum  \count 0 < -32767
  517.                 \then   \divide \count 0 by 4
  518.                         \divide \count 4 by 4
  519.                 \else
  520.                 \fi
  521.         \fi
  522.         \ifnum  \count 2 > 32767 %%% while retaining reasonable accuracy
  523.         \then   \divide \count 2 by 4
  524.                 \divide \count 4 by 4
  525.         \else   \ifnum  \count 2 < -32767
  526.                 \then   \divide \count 2 by 4
  527.                         \divide \count 4 by 4
  528.                 \else
  529.                 \fi
  530.         \fi
  531.         \multiply \count 0 by \count 2
  532.         \divide \count 0 by \count 4
  533.         \xdef \product {#1 = \the \count 0 \internal@nits}%
  534.         \aftergroup \product
  535.        }}%
  536.  
  537. \def\r@duce{\ifdim\dimen0 > 90\r@dian \then   % sin(x) = sin(180-x)
  538.                 \multiply\dimen0 by -1
  539.                 \advance\dimen0 by 180\r@dian
  540.                 \r@duce
  541.             \else \ifdim\dimen0 < -90\r@dian \then  % sin(x) = sin(360+x)
  542.                 \advance\dimen0 by 360\r@dian
  543.                 \r@duce
  544.                 \fi
  545.             \fi}%
  546.  
  547. \def\Sine#1%
  548.        {{%
  549.         \dimen 0 = #1 \r@dian
  550.         \r@duce
  551.         \ifdim\dimen0 = -90\r@dian \then
  552.            \dimen4 = -1\r@dian
  553.            \c@mputefalse
  554.         \fi
  555.         \ifdim\dimen0 = 90\r@dian \then
  556.            \dimen4 = 1\r@dian
  557.            \c@mputefalse
  558.         \fi
  559.         \ifdim\dimen0 = 0\r@dian \then
  560.            \dimen4 = 0\r@dian
  561.            \c@mputefalse
  562.         \fi
  563. %
  564.         \ifc@mpute \then
  565.                 % convert degrees to radians
  566.                 \divide\dimen0 by 180
  567.                 \dimen0=3.141592654\dimen0
  568. %
  569.                 \dimen 2 = 3.1415926535897963\r@dian %%% a well-known constant
  570.                 \divide\dimen 2 by 2 %%% we only deal with -pi/2 : pi/2
  571.                 \Mess@ge {Sin: calculating Sin of \nodimen 0}%
  572.                 \count 0 = 1 %%% see power-series expansion for sine
  573.                 \dimen 2 = 1 \r@dian %%% ditto
  574.                 \dimen 4 = 0 \r@dian %%% ditto
  575.                 \loop
  576.                         \ifnum  \dimen 2 = 0 %%% then we've done
  577.                         \then   \stillc@nvergingfalse
  578.                         \else   \stillc@nvergingtrue
  579.                         \fi
  580.                         \ifstillc@nverging %%% then calculate next term
  581.                         \then   \term {\count 0} {\dimen 0} {\dimen 2}%
  582.                                 \advance \count 0 by 2
  583.                                 \count 2 = \count 0
  584.                                 \divide \count 2 by 2
  585.                                 \ifodd  \count 2 %%% signs alternate
  586.                                 \then   \advance \dimen 4 by \dimen 2
  587.                                 \else   \advance \dimen 4 by -\dimen 2
  588.                                 \fi
  589.                 \repeat
  590.         \fi
  591.                         \xdef \sine {\nodimen 4}%
  592.        }}%
  593.  
  594. %%% Now the Cosine can be calculated easily by calling \Sine:
  595. %%%  cos(x) = sin(90-x)
  596. \def\Cosine#1{\ifx\sine\UnDefined\edef\Savesine{\relax}\else
  597.                              \edef\Savesine{\sine}\fi
  598.         {\dimen0=#1\r@dian\multiply\dimen0 by -1
  599.          \advance\dimen0 by 90\r@dian
  600.          \Sine{\nodimen 0}%
  601.          \xdef\cosine{\sine}%
  602.          \xdef\sine{\Savesine}}}
  603. %%% end of trig stuff
  604. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  605. %
  606. \def\psdraft{\def\@psdraft{0}}%
  607. \def\psfull{\def\@psdraft{1}}%
  608. \psfull
  609. \newif\if@compress
  610. \def\pscompress{\@compresstrue}
  611. \def\psnocompress{\@compressfalse}
  612. \@compressfalse
  613. \newif\if@scalefirst
  614. \def\psscalefirst{\@scalefirsttrue}%
  615. \def\psrotatefirst{\@scalefirstfalse}%
  616. \psrotatefirst
  617. %
  618. \newif\if@draftbox
  619. \def\psnodraftbox{\@draftboxfalse}%
  620. \@draftboxtrue
  621. %
  622. \newif\if@noisy
  623. \@noisyfalse
  624. \newif\ifno@bb
  625. %%% These are for the option list.
  626. %%% A specification of the form a = b maps to calling \@p@@sa{b}%
  627. \newif\if@bbllx
  628. \newif\if@bblly
  629. \newif\if@bburx
  630. \newif\if@bbury
  631. \newif\if@height
  632. \newif\if@width
  633. \newif\if@rheight
  634. \newif\if@rwidth
  635. \newif\if@angle
  636. \newif\if@clip
  637. \newif\if@verbose
  638. \newif\if@prologfile
  639. \def\@p@@sprolog#1{\@prologfiletrue\def\@prologfileval{#1}}%
  640. \def\@p@@sclip#1{\@cliptrue}%
  641. %
  642. \newif\ifepsfig@dos  % only single suffix possible
  643. \def\epsfigdos{\epsfig@dostrue}%
  644. \epsfig@dosfalse
  645. %%% if this is true, the original Darrell macros and specials are used
  646. \newif\ifuse@psfig
  647. %
  648. \def\ParseName#1{\expandafter\@Parse#1}%
  649. \def\@Parse#1.#2:{\gdef\BaseName{#1}\gdef\FileType{#2}}%
  650.  
  651. \def\@p@@sfile#1{%
  652.   \ifepsfig@dos
  653.      \ParseName{#1:}%
  654.   \else
  655.      \gdef\BaseName{#1}\gdef\FileType{}%
  656.   \fi
  657.   \def\@p@sfile{NO FILE: #1}%
  658.   \def\@p@sfilefinal{NO FILE: #1}%
  659.   \openin1=#1
  660.   \ifeof1\closein1\openin1=\BaseName.bb
  661.     \ifeof1\closein1
  662.       \if@bbllx                 % No postscript file but bb given explicitly.
  663.         \if@bblly\if@bburx\if@bbury
  664.           \def\@p@sfile{#1}%
  665.           \def\@p@sfilefinal{#1}%
  666.         \fi\fi\fi
  667.       \else                     % No bounding box found.
  668.         \@latexerr{ERROR. PostScript file #1 not found}\@whattodo
  669.         \@p@@sbbllx{100bp}%
  670.         \@p@@sbblly{100bp}%
  671.         \@p@@sbburx{200bp}%
  672.         \@p@@sbbury{200bp}%
  673.         \psdraft
  674.       \fi
  675.     \else                       % Postscript file is compressed.
  676.       \closein1%
  677.       \edef\@p@sfile{\BaseName.bb}%
  678.       \typeout{using BB from \@p@sfile}%
  679.       \ifnum\fig@driver=3
  680.         \edef\@p@sfilefinal{\BaseName.pcx}%
  681.       \else
  682.         \ifepsfig@dos
  683.           \edef\@p@sfilefinal{"`gunzip -c `texfind \BaseName.{z,Z,gz}"}%
  684.         \else
  685.           \edef\@p@sfilefinal{"`epsfig \if@compress-c \fi#1"}%          
  686.         \fi
  687.       \fi
  688.     \fi
  689.   \else\closein1                % Postscript file is not compressed.
  690.     \edef\@p@sfile{#1}%
  691.     \if@compress  
  692.       \edef\@p@sfilefinal{"`epsfig -c #1"}%
  693.     \else
  694.       \edef\@p@sfilefinal{#1}%
  695.     \fi
  696.   \fi%
  697. }
  698.  
  699. % alternative syntax: figure=
  700. \let\@p@@sfigure\@p@@sfile
  701. %
  702. \def\@p@@sbbllx#1{%
  703.                                             \@bbllxtrue
  704.                 \ps@dimcent=#1
  705.                 \edef\@p@sbbllx{\number\ps@dimcent}%
  706.                 \divide\ps@dimcent by65536
  707.                 \global\edef\epsfllx{\number\ps@dimcent}%
  708. }%
  709. \def\@p@@sbblly#1{%
  710.                 \@bbllytrue
  711.                 \ps@dimcent=#1
  712.                 \edef\@p@sbblly{\number\ps@dimcent}%
  713.                 \divide\ps@dimcent by65536
  714.                 \global\edef\epsflly{\number\ps@dimcent}%
  715. }%
  716. \def\@p@@sbburx#1{%
  717.                 \@bburxtrue
  718.                 \ps@dimcent=#1
  719.                 \edef\@p@sbburx{\number\ps@dimcent}%
  720.                 \divide\ps@dimcent by65536
  721.                 \global\edef\epsfurx{\number\ps@dimcent}%
  722. }%
  723. \def\@p@@sbbury#1{%
  724.                 \@bburytrue
  725.                 \ps@dimcent=#1
  726.                 \edef\@p@sbbury{\number\ps@dimcent}%
  727.                 \divide\ps@dimcent by65536
  728.                 \global\edef\epsfury{\number\ps@dimcent}%
  729. }%
  730. \def\@p@@sheight#1{%
  731.                 \@heighttrue
  732.                 \global\epsfysize=#1
  733.                 \ps@dimcent=#1
  734.                 \edef\@p@sheight{\number\ps@dimcent}%
  735. }%
  736. \def\@p@@swidth#1{%
  737.                 \@widthtrue
  738.                 \global\epsfxsize=#1
  739.                 \ps@dimcent=#1
  740.                 \edef\@p@swidth{\number\ps@dimcent}% 
  741. }%
  742. \def\@p@@srheight#1{%
  743.                 \@rheighttrue\use@psfigtrue
  744.                 \ps@dimcent=#1
  745.                 \edef\@p@srheight{\number\ps@dimcent}%
  746. }%
  747. \def\@p@@srwidth#1{%
  748.                 \@rwidthtrue\use@psfigtrue
  749.                 \ps@dimcent=#1
  750.                 \edef\@p@srwidth{\number\ps@dimcent}%
  751. }%
  752. \def\@p@@sangle#1{%
  753.                 \use@psfigtrue
  754.                 \@angletrue
  755.                 \edef\@p@sangle{#1}%
  756. }%
  757. \def\@p@@ssilent#1{%
  758.                 \@verbosefalse
  759. }%
  760. \def\@p@@snoisy#1{%
  761.                 \@verbosetrue
  762. }%
  763. \def\@cs@name#1{\csname #1\endcsname}%
  764. \def\@setparms#1=#2,{\@cs@name{@p@@s#1}{#2}}%
  765. %
  766. %%% initialize the defaults (size the size of the figure)
  767. %
  768. \def\ps@init@parms{%
  769.                 \@bbllxfalse \@bbllyfalse
  770.                 \@bburxfalse \@bburyfalse
  771.                 \@heightfalse \@widthfalse
  772.                 \@rheightfalse \@rwidthfalse
  773.                 \def\@p@sbbllx{}\def\@p@sbblly{}%
  774.                 \def\@p@sbburx{}\def\@p@sbbury{}%
  775.                 \def\@p@sheight{}\def\@p@swidth{}%
  776.                 \def\@p@srheight{}\def\@p@srwidth{}%
  777.                 \def\@p@sangle{0}%
  778.                 \def\@p@sfile{}%
  779.                 \use@psfigfalse
  780.                 \@prologfilefalse
  781.                 \def\@sc{}%
  782.                 \if@noisy
  783.                         \@verbosetrue
  784.                 \else
  785.                         \@verbosefalse
  786.                 \fi
  787.                 \@clipfalse
  788. }%
  789. %
  790. %%% Go through the options setting things up.
  791. %
  792. \def\parse@ps@parms#1{%
  793.                 \@psdo\@psfiga:=#1\do
  794.                    {\expandafter\@setparms\@psfiga,}%
  795. \if@prologfile
  796. \special{header=\@prologfileval}%
  797. \fi
  798. }%
  799. %
  800. %%% Compute bb height and width
  801. %
  802. \def\bb@missing{%
  803.         \if@verbose
  804.             \typeout{psfig: searching \@p@sfile \space  for bounding box}%
  805.         \fi
  806.         \epsfgetbb{\@p@sfile}%
  807.         \ifepsfbbfound
  808.             \ps@dimcent=\epsfllx bp\edef\@p@sbbllx{\number\ps@dimcent}%
  809.             \ps@dimcent=\epsflly bp\edef\@p@sbblly{\number\ps@dimcent}%
  810.             \ps@dimcent=\epsfurx bp\edef\@p@sbburx{\number\ps@dimcent}%
  811.             \ps@dimcent=\epsfury bp\edef\@p@sbbury{\number\ps@dimcent}%
  812.         \else
  813.             \epsfbbfoundfalse
  814.         \fi
  815. }
  816. %
  817. % rotate point (#1,#2) about (0,0).
  818. % The sine and cosine of the angle are already stored in \sine and
  819. % \cosine.  The result is placed in (\p@intvaluex, \p@intvaluey).
  820. \newdimen\p@intvaluex
  821. \newdimen\p@intvaluey
  822. \def\rotate@#1#2{{\dimen0=#1 sp\dimen1=#2 sp
  823. %               calculate x' = x \cos\theta - y \sin\theta
  824.                   \global\p@intvaluex=\cosine\dimen0
  825.                   \dimen3=\sine\dimen1
  826.                   \global\advance\p@intvaluex by -\dimen3
  827. %               calculate y' = x \sin\theta + y \cos\theta
  828.                   \global\p@intvaluey=\sine\dimen0
  829.                   \dimen3=\cosine\dimen1
  830.                   \global\advance\p@intvaluey by \dimen3
  831.                   }}%
  832. \def\compute@bb{%
  833.                 \epsfbbfoundfalse
  834.                 \if@bbllx\epsfbbfoundtrue\fi
  835.                 \if@bblly\epsfbbfoundtrue\fi
  836.                 \if@bburx\epsfbbfoundtrue\fi
  837.                 \if@bbury\epsfbbfoundtrue\fi
  838.                 \ifepsfbbfound\else\bb@missing\fi
  839.                 \ifepsfbbfound\else
  840.                 \@latexerr{ERROR. cannot locate BoundingBox}\@whattodobb
  841.                         \@p@@sbbllx{100bp}%
  842.                         \@p@@sbblly{100bp}%
  843.                         \@p@@sbburx{200bp}%
  844.                         \@p@@sbbury{200bp}%
  845.                         \no@bbtrue
  846.                         \psdraft
  847.                 \fi
  848.                 %
  849. %
  850. % store height/width of original (unrotated) bounding box
  851.                 \count203=\@p@sbburx
  852.                 \count204=\@p@sbbury
  853.                 \advance\count203 by -\@p@sbbllx
  854.                 \advance\count204 by -\@p@sbblly
  855.                 \edef\ps@bbw{\number\count203}%
  856.                 \edef\ps@bbh{\number\count204}%
  857.                  \edef\@bbw{\number\count203}%
  858.                 \edef\@bbh{\number\count204}%
  859.                \if@angle
  860.                         \Sine{\@p@sangle}\Cosine{\@p@sangle}%
  861.  
  862. {\ps@dimcent=\maxdimen\xdef\r@p@sbbllx{\number\ps@dimcent}%
  863.  
  864. \xdef\r@p@sbblly{\number\ps@dimcent}%
  865.  
  866. \xdef\r@p@sbburx{-\number\ps@dimcent}%
  867.  
  868. \xdef\r@p@sbbury{-\number\ps@dimcent}}%
  869. %
  870. % Need to rotate all four points and take the X-Y extremes of the new
  871. % points as the new bounding box.
  872.                         \def\minmaxtest{%
  873.                            \ifnum\number\p@intvaluex<\r@p@sbbllx
  874.                               \xdef\r@p@sbbllx{\number\p@intvaluex}\fi
  875.                            \ifnum\number\p@intvaluex>\r@p@sbburx
  876.                               \xdef\r@p@sbburx{\number\p@intvaluex}\fi
  877.                            \ifnum\number\p@intvaluey<\r@p@sbblly
  878.                               \xdef\r@p@sbblly{\number\p@intvaluey}\fi
  879.                            \ifnum\number\p@intvaluey>\r@p@sbbury
  880.                               \xdef\r@p@sbbury{\number\p@intvaluey}\fi
  881.                            }%
  882. %                       lower left
  883.                         \rotate@{\@p@sbbllx}{\@p@sbblly}%
  884.                         \minmaxtest
  885. %                       upper left
  886.                         \rotate@{\@p@sbbllx}{\@p@sbbury}%
  887.                         \minmaxtest
  888. %                       lower right
  889.                         \rotate@{\@p@sbburx}{\@p@sbblly}%
  890.                         \minmaxtest
  891. %                       upper right
  892.                         \rotate@{\@p@sbburx}{\@p@sbbury}%
  893.                         \minmaxtest
  894.  
  895. \edef\@p@sbbllx{\r@p@sbbllx}\edef\@p@sbblly{\r@p@sbblly}%
  896.  
  897. \edef\@p@sbburx{\r@p@sbburx}\edef\@p@sbbury{\r@p@sbbury}%
  898.                 \fi
  899.                 \count203=\@p@sbburx
  900.                 \count204=\@p@sbbury
  901.                 \advance\count203 by -\@p@sbbllx
  902.                 \advance\count204 by -\@p@sbblly
  903.                 \edef\@bbw{\number\count203}%
  904.                 \edef\@bbh{\number\count204}%
  905. }%
  906. %
  907. % \in@hundreds performs #1 * (#2 / #3) correct to the hundreds,
  908. %       then leaves the result in @result
  909. %
  910. \def\in@hundreds#1#2#3{\count240=#2 \count241=#3
  911.                      \count100=\count240        % 100 is first digit #2/#3
  912.                      \divide\count100 by \count241
  913.                      \count101=\count100
  914.                      \multiply\count101 by \count241
  915.                      \advance\count240 by -\count101
  916.                      \multiply\count240 by 10
  917.                      \count101=\count240        %101 is second digit of #2/#3
  918.                      \divide\count101 by \count241
  919.                      \count102=\count101
  920.                      \multiply\count102 by \count241
  921.                      \advance\count240 by -\count102
  922.                      \multiply\count240 by 10
  923.                      \count102=\count240        % 102 is the third digit
  924.                      \divide\count102 by \count241
  925.                      \count200=#1\count205=0
  926.                      \count201=\count200
  927.                         \multiply\count201 by \count100
  928.                         \advance\count205 by \count201
  929.                      \count201=\count200
  930.                         \divide\count201 by 10
  931.                         \multiply\count201 by \count101
  932.                         \advance\count205 by \count201
  933.                         %
  934.                      \count201=\count200
  935.                         \divide\count201 by 100
  936.                         \multiply\count201 by \count102
  937.                         \advance\count205 by \count201
  938.                         %
  939.                      \edef\@result{\number\count205}%
  940. }%
  941. \def\compute@wfromh{%
  942.                 % computing : width = height * (bbw / bbh)
  943.                 \in@hundreds{\@p@sheight}{\@bbw}{\@bbh}%
  944.                 \edef\@p@swidth{\@result}%
  945. }%
  946. \def\compute@hfromw{%
  947.                 % computing : height = width * (bbh / bbw)
  948.                 \in@hundreds{\@p@swidth}{\@bbh}{\@bbw}%
  949.                 \edef\@p@sheight{\@result}%
  950. }%
  951. \def\compute@handw{%
  952.                 \if@height
  953.                         \if@width
  954.                         \else
  955.                                 \compute@wfromh
  956.                         \fi
  957.                 \else
  958.                         \if@width
  959.                                 \compute@hfromw
  960.                         \else
  961.                                 \edef\@p@sheight{\@bbh}%
  962.                                 \edef\@p@swidth{\@bbw}%
  963.                         \fi
  964.                 \fi
  965. }%
  966. \def\compute@resv{%
  967.                 \if@rheight \else \edef\@p@srheight{\@p@sheight} \fi
  968.                 \if@rwidth \else \edef\@p@srwidth{\@p@swidth} \fi
  969. }%
  970. %
  971. % Compute any missing values
  972. \def\compute@sizes{%
  973.         \if@scalefirst\if@angle
  974. % at this point the bounding box has been adjsuted correctly for
  975. % rotation.  PSFIG does all of its scaling using \@bbh and \@bbw.  If
  976. % a width= or height= was specified along with \psscalefirst, then the
  977. % width=/height= value needs to be adjusted to match the new (rotated)
  978. % bounding box size (specifed in \@bbw and \@bbh).
  979. %    \ps@bbw       width=
  980. %    -------  =  ----------
  981. %    \@bbw       new width=
  982. % so `new width=' = (width= * \@bbw) / \ps@bbw; where \ps@bbw is the
  983. % width of the original (unrotated) bounding box.
  984.         \if@width
  985.            \in@hundreds{\@p@swidth}{\@bbw}{\ps@bbw}%
  986.            \edef\@p@swidth{\@result}%
  987.         \fi
  988.         \if@height
  989.            \in@hundreds{\@p@sheight}{\@bbh}{\ps@bbh}%
  990.            \edef\@p@sheight{\@result}%
  991.         \fi
  992.         \fi\fi
  993.         \compute@handw
  994.         \compute@resv
  995. }
  996. %
  997.  
  998. %------------------------------------------------------------------
  999. %%% by the way, possible parameters to the PSfile= command in dvips are:
  1000. %%%                    llx
  1001. %%%                    lly
  1002. %%%                    urx
  1003. %%%                    ury
  1004. %%%                    rwi
  1005. %       hoffset The horizontal offset (default 0)
  1006. %       voffset The vertical offset (default 0)
  1007. %       hsize   The horizontal clipping size (default 612)
  1008. %       vsize   The vertical clipping size (default 792)
  1009. %       hscale  The horizontal scaling factor (default 100)
  1010. %       vscale  The vertical scaling factor (default 100)
  1011. %       angle   The rotation (default 0)
  1012. %------------------------------------------------------------------
  1013. \long\def\graphic@verb#1{\def\next{#1}%
  1014.   {\expandafter\graphic@strip\meaning\next}}
  1015. \def\graphic@strip#1>{}
  1016. \def\graphic@zapspace#1{%
  1017.   #1\ifx\graphic@zapspace#1\graphic@zapspace%
  1018.   \else\expandafter\graphic@zapspace%
  1019.   \fi}
  1020. \def\psfig#1{%
  1021. \edef\@tempa{\graphic@zapspace#1{}}%
  1022. \ifvmode\leavevmode\fi\vbox {%
  1023.         %
  1024.         \ps@init@parms
  1025.         \parse@ps@parms{\@tempa}%
  1026.         %
  1027.         \ifnum\@psdraft=1
  1028.                 \typeout{[\@p@sfilefinal]}%
  1029.                 \if@verbose
  1030.                         \typeout{epsfig: using PSFIG macros}%
  1031.                 \fi
  1032.                 \psfig@method
  1033.         \else
  1034.                 \epsfig@draft
  1035.         \fi
  1036. }
  1037. }%
  1038. \def\graphic@zapspace#1{%
  1039.   #1\ifx\graphic@zapspace#1\graphic@zapspace%
  1040.   \else\expandafter\graphic@zapspace%
  1041.   \fi}
  1042. \def\epsfig#1{%
  1043. \edef\@tempa{\graphic@zapspace#1{}}%
  1044. \ifvmode\leavevmode\fi\vbox {%
  1045.         %
  1046.         \ps@init@parms
  1047.         \parse@ps@parms{\@tempa}%
  1048.         %
  1049.         \ifnum\@psdraft=1
  1050.           \if@angle\use@psfigtrue\fi
  1051.           {\ifnum\fig@driver=1\global\use@psfigtrue\fi}%
  1052.           {\ifnum\fig@driver=3\global\use@psfigtrue\fi}%
  1053.           {\ifnum\fig@driver=4\global\use@psfigtrue\fi}%
  1054.           {\ifnum\fig@driver=5\global\use@psfigtrue\fi}%
  1055.                 \ifuse@psfig
  1056.                         \if@verbose
  1057.                                 \typeout{epsfig: using PSFIG macros}%
  1058.                         \fi
  1059.                         \psfig@method
  1060.                 \else
  1061.                         \if@verbose
  1062.                                 \typeout{epsfig: using EPSF macros}%
  1063.                         \fi
  1064.                         \epsf@method
  1065.                 \fi
  1066.         \else
  1067.                 \epsfig@draft
  1068.         \fi
  1069. }%
  1070. }%
  1071.  
  1072.  
  1073. \def\epsf@method{%
  1074.         \epsfbbfoundfalse
  1075.         \if@bbllx\epsfbbfoundtrue\fi
  1076.         \if@bblly\epsfbbfoundtrue\fi
  1077.         \if@bburx\epsfbbfoundtrue\fi
  1078.         \if@bbury\epsfbbfoundtrue\fi
  1079.         \ifepsfbbfound\else\epsfgetbb{\@p@sfile}\fi
  1080.         \ifepsfbbfound
  1081.            \typeout{<\@p@sfilefinal>}%
  1082.            \epsfig@gofer
  1083.         \else
  1084.           \@latexerr{ERROR - Cannot locate BoundingBox}\@whattodobb
  1085.           \@p@@sbbllx{100bp}%
  1086.           \@p@@sbblly{100bp}%
  1087.           \@p@@sbburx{200bp}%
  1088.           \@p@@sbbury{200bp}%
  1089.                 \count203=\@p@sbburx
  1090.                 \count204=\@p@sbbury
  1091.                 \advance\count203 by -\@p@sbbllx
  1092.                 \advance\count204 by -\@p@sbblly
  1093.                 \edef\@bbw{\number\count203}%
  1094.                 \edef\@bbh{\number\count204}%
  1095.           \compute@sizes
  1096.           \epsfig@@draft
  1097.        \fi
  1098. }%
  1099. \def\psfig@method{%
  1100.         \compute@bb
  1101.         \ifepsfbbfound
  1102.           \compute@sizes
  1103.           \psfig@start
  1104.           % Create the vbox to reserve the space for the figure%
  1105.           \vbox to \@p@srheight sp{\hbox to \@p@srwidth 
  1106.             sp{\hss}\vss\psfig@end}%
  1107.         \else
  1108.            \epsfig@draft
  1109.         \fi
  1110. }%
  1111. %
  1112. % draft figure, just reserve the space and print the
  1113. % path name.
  1114. \def\epsfig@draft{\compute@bb\compute@sizes\epsfig@@draft}%
  1115. %
  1116. \def\epsfig@@draft{%
  1117. \typeout{<(draft only) \@p@sfilefinal>}%
  1118. \if@draftbox
  1119.         % Verbose draft: print file name in box
  1120.         \hbox{{\fboxsep0pt\fbox{\vbox to \@p@srheight sp{%
  1121.         \vss\hbox to \@p@srwidth sp{ \hss 
  1122.            \expandafter\Literally\@p@sfilefinal\@nil
  1123.                           \hss }\vss
  1124.         }}}}%
  1125. \else
  1126.         % Non-verbose draft
  1127.         \vbox to \@p@srheight sp{%
  1128.         \vss\hbox to \@p@srwidth sp{\hss}\vss}%
  1129. \fi
  1130. }%
  1131. \def\Literally#1\@nil{{\tt\graphic@verb{#1}}}
  1132. % default to dvips
  1133. \psfigdriver{dvips}%
  1134. % and to DOS file conventions
  1135. %%% \epsfigdos
  1136. \epsfigRestoreAt
  1137.  
  1138.